package example.pattern.iterator;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		final Double upPrice = Double.valueOf(15);
		BookShelf<Book> bs = new BookShelf<Book>();
		bs.add(new Book("1", 10.0d));
		bs.add(new Book("2", 20d));
		bs.add(new Book("3", 21d));
		bs.add(new Book("4", 11d));
		for (java.util.Iterator<Book> iter = bs.iterator(); iter.hasNext();) {
			Book book = iter.next();
			System.out.println(book);
			if (book.getPrice().compareTo(upPrice) > 0) {
				System.out.println("removed " + book);
				iter.remove();
			}
		}
		bs.add(new Book("5", 14d));
		bs.add(new Book("6", 18.4d));
		for (Book book : bs) {
			System.out.println(book);
		}
		System.out.println("---------end------------");
	}

}
